package krao.data;

import java.util.ArrayList;

/**
 * Class for storing data for one tbox property. Also stored here are the
 * domains/ranges of this property, along with sub-properties, super-properties
 * and inverse properties.
 * 
 * @author Pepe
 * 
 */
public class TBoxProperty {
	private String name;
	private ArrayList<TBoxClass> domain;
	private ArrayList<TBoxClass> range;
	private ArrayList<String> subProp;
	private ArrayList<String> superProp;
	private ArrayList<String> inverseProp;

	public TBoxProperty(String newName) {
		this.setName(newName);
		setDomain(new ArrayList<TBoxClass>());
		setRange(new ArrayList<TBoxClass>());
		setSubproperties(new ArrayList<String>());
		setSuperProp(new ArrayList<String>());
		setInverseProp(new ArrayList<String>());
	}

	private void setInverseProp(ArrayList<String> inverseProps) {
		inverseProp = inverseProps;
	}

	public ArrayList<String> getSuperProp() {
		return superProp;
	}

	public void setSuperProp(ArrayList<String> superProp) {
		this.superProp = superProp;
	}

	public void addDomain(TBoxClass newDomain) {
		if (getDomain() != null && !this.getDomain().contains(newDomain)) {
			this.getDomain().add(newDomain);
		}
	}

	public void addRange(TBoxClass newRange) {
		if (getRange() != null && !this.getRange().contains(newRange)) {
			this.getRange().add(newRange);
		}
	}

	public void addSuperProp(String superPropName) {
		if (superProp != null && !this.superProp.contains(superPropName)) {
			this.superProp.add(superPropName);
		}
	}

	public void addSubProp(String thisPropName) {
		if (getSubProperties() != null && !this.getSubProperties().contains(thisPropName)) {
			this.getSubProperties().add(thisPropName);
		}
	}

	public void addInverseProp(String thisPropName) {
		if (getInverseProp() != null && !this.getInverseProp().contains(thisPropName)) {
			this.getInverseProp().add(thisPropName);
		}
	}

	public ArrayList<String> getInverseProp() {
		return inverseProp;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder(String.format("%s[Domain:", getName()));
		for (TBoxClass oneDomain : getDomain()) {
			sb.append(oneDomain.getName());
			sb.append(", ");
		}
		sb.append("\tRange: ");
		for (TBoxClass oneRange : getRange()) {
			sb.append(oneRange.getName());
			sb.append(", ");
		}
		sb.append("]\n\t[Super:");
		for (String oneSuperproperty : superProp) {
			sb.append(oneSuperproperty);
			sb.append(", ");
		}
		sb.append("\tSub: ");
		for (String oneSubproperty : getSubProperties()) {
			sb.append(oneSubproperty);
			sb.append(", ");
		}
		sb.append("]\n");
		return sb.toString();

	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public ArrayList<TBoxClass> getRange() {
		return range;
	}

	public void setRange(ArrayList<TBoxClass> range) {
		this.range = range;
	}

	public ArrayList<TBoxClass> getDomain() {
		return domain;
	}

	public void setDomain(ArrayList<TBoxClass> domain) {
		this.domain = domain;
	}

	public ArrayList<String> getSubProperties() {
		return subProp;
	}

	public void setSubproperties(ArrayList<String> subproperties) {
		this.subProp = subproperties;
	}
}
